package com.hz.monitoring.module.hardware.dal.mysql.sensor_sys_type;

import com.hz.monitoring.framework.common.pojo.PageResult;
import com.hz.monitoring.framework.mybatis.core.mapper.BaseMapperX;
import com.hz.monitoring.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.hz.monitoring.module.hardware.controller.admin.sensor_sys_type.vo.SensorSysTypeExportReqVO;
import com.hz.monitoring.module.hardware.controller.admin.sensor_sys_type.vo.SensorSysTypeListReqVO;
import com.hz.monitoring.module.hardware.controller.admin.sensor_sys_type.vo.SensorSysTypePageReqVO;
import com.hz.monitoring.module.hardware.dal.dataobject.sensor_sys_type.SensorSysTypeDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 传感器系统分类 Mapper
 *
 * @author lin
 */
@Mapper
public interface SensorSysTypeMapper extends BaseMapperX<SensorSysTypeDO> {

    default PageResult<SensorSysTypeDO> selectPage(SensorSysTypePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SensorSysTypeDO>()
                .eqIfPresent(SensorSysTypeDO::getMcuModel, reqVO.getMcuModel())
                .likeIfPresent(SensorSysTypeDO::getName, reqVO.getName())
                .eqIfPresent(SensorSysTypeDO::getModel, reqVO.getModel())
                .likeIfPresent(SensorSysTypeDO::getVendor, reqVO.getVendor())
                .eqIfPresent(SensorSysTypeDO::getEdition, reqVO.getEdition())
                .likeIfPresent(SensorSysTypeDO::getSpecification, reqVO.getSpecification())
                .betweenIfPresent(SensorSysTypeDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(SensorSysTypeDO::getId));
    }

    default List<SensorSysTypeDO> selectList(SensorSysTypeListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<SensorSysTypeDO>()
                .eqIfPresent(SensorSysTypeDO::getMcuModel, reqVO.getMcuModel())
                .likeIfPresent(SensorSysTypeDO::getName, reqVO.getName())
                .eqIfPresent(SensorSysTypeDO::getModel, reqVO.getModel())
                .likeIfPresent(SensorSysTypeDO::getVendor, reqVO.getVendor())
                .eqIfPresent(SensorSysTypeDO::getEdition, reqVO.getEdition())
                .likeIfPresent(SensorSysTypeDO::getSpecification, reqVO.getSpecification())
                .betweenIfPresent(SensorSysTypeDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .inIfPresent(SensorSysTypeDO::getId,reqVO.getIds())
                .betweenIfPresent(SensorSysTypeDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(SensorSysTypeDO::getId));
    }


    default List<SensorSysTypeDO> selectList(SensorSysTypeExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<SensorSysTypeDO>()
                .eqIfPresent(SensorSysTypeDO::getMcuModel, reqVO.getMcuModel())
                .likeIfPresent(SensorSysTypeDO::getName, reqVO.getName())
                .eqIfPresent(SensorSysTypeDO::getModel, reqVO.getModel())
                .likeIfPresent(SensorSysTypeDO::getVendor, reqVO.getVendor())
                .eqIfPresent(SensorSysTypeDO::getEdition, reqVO.getEdition())
                .likeIfPresent(SensorSysTypeDO::getSpecification, reqVO.getSpecification())
                .betweenIfPresent(SensorSysTypeDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .betweenIfPresent(SensorSysTypeDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(SensorSysTypeDO::getId));
    }

}
